/**
 * Created by liuyunfei on 2016-12-30.
 */
module.exports = function ($http,$q,httpservice) {
    var userInfoService = {};

    /**
     * 完善用户信息
     * @param id
     * @param username
     * @param cellphone
     * @param lawfirmid
     * @param entryyear
     * @param certificateno
     * @returns {*}
     */
    userInfoService.updateUserInfo = function (id,username,lawfirmid,entryyear,certificateno) {
        var params={"id":id,"username":username,"lawfirmid":lawfirmid,"entryyear":entryyear,"certificateno":certificateno};
        var deferred = $q.defer();
        $http({
            method: 'PUT',
            url: httpservice.updateUserInfoUrl,
            data:params,
            headers : {'Content-Type':'application/json'}
        }).then(function successCallback(response) {
            deferred.resolve(response.data);
        }, function errorCallback(response) {
            deferred.reject(response);
        });
        return deferred.promise;
    }

    /**
     * 获取律所列表
     * @returns {*}
     */
    userInfoService.getLawFirms = function () {
        var deferred = $q.defer();
        $http({
            method: 'GET',
            url: httpservice.lawfirmsUrl,
            //headers : {'Content-Type':'application/json'}
        }).then(function successCallback(response) {
            deferred.resolve(response.data);
        }, function errorCallback(response) {
            deferred.reject(response);
        });
        return deferred.promise;
    };


    return userInfoService;
}
